const http = require('http');

const server = http.createServer((req, res) => {
    if (req.method === 'POST') {
        let body = '';
        req.on('data', (chunk) => {
            body += chunk;
        });

        req.on('end', () => {
            res.writeHead(200, {'Content-Type': 'text/plain'});
            res.end('Received data: ' + body);
        });
    } else {
        res.writeHead(405, {'Content-Type': 'text/plain'});
        res.end('Method Not Allowed');
    }
});

const port = 3001;
server.listen(port, () => {
    console.log(`Server is running on port ${port}`);
});
